fix(PLA-3414): copyrigth text check - #40
Conversation
There was a problem hiding this comment.
Pull request overview
Adds copyright-header validation and remediation using HashiCorp Copywrite.
Changes:
- Adds Copywrite configuration and CCDC header templates.
- Adds check and fix shell hooks.
- Integrates header validation into the composite action.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
action.yml |
Installs and runs Copywrite. |
.pre-commit-hook.yaml |
Registers check and fix hooks. |
main/hooks/copywrite_check.sh |
Checks header compliance. |
main/hooks/copywrite_fix.sh |
Applies compliant headers. |
main/copywrite/.copywrite.hcl |
Defines header rules and exclusions. |
main/copywrite/headers/ccdc_hash.tmpl |
Adds hash-comment header template. |
main/copywrite/headers/ccdc_slash.tmpl |
Adds slash-comment header template. |
Suppressed comments (1)
.pre-commit-hook.yaml:9
- This entry points to a nonexistent root-level script; the added fixer is under
main/hooks. The manual hook will therefore fail to start.
entry: hooks/copywrite_fix.sh
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Suppressed comments (1)
action.yml:15
- This makes only the config path action-relative; the config still names both templates as relative
main/copywrite/headers/...paths. Composite action commands run in the caller's workspace, so external consumers do not have those paths and header validation fails while loading the templates (the self-test masks this because its workspace is this repository). Make the template paths resolve from$GITHUB_ACTION_PATHwithout changing the workspace that Copywrite scans.
run: copywrite headers --config "$GITHUB_ACTION_PATH/main/copywrite/.copywrite.hcl" --plan
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Suppressed comments (1)
Previously missed (1) — in code that hasn't changed since the last review.
action.yml:15
- This invokes Copywrite without restricting it to the commit's files, so it validates the entire checkout. That breaks the composite action's documented changed-file scope (
action.yml:3andmain.py:23-40) and can reject a PR because of an untouched historical file. Limit header validation to the modified/added files selected byget_commit_files, or expose repository-wide validation as an explicitly documented opt-in.
run: copywrite headers --config "$GITHUB_ACTION_PATH/main/copywrite/.copywrite.hcl" --plan
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Suppressed comments (2)
main/hooks/copywrite_check.sh:4
- This path is resolved from
main/hooks, so it points to the nonexistentmain/hooks/main/copywrite/.copywrite.hcl. The check hook exits before checking any headers; reference the siblingcopywritedirectory instead.
copywrite headers --config="$(dirname "${BASH_SOURCE[0]}")/main/copywrite/.copywrite.hcl" --plan
main/hooks/copywrite_fix.sh:4
- This path is resolved from
main/hooks, so it points to the nonexistentmain/hooks/main/copywrite/.copywrite.hcl. The manual fix hook therefore cannot run; reference the siblingcopywritedirectory instead.
copywrite headers --config="$(dirname "${BASH_SOURCE[0]}")/main/copywrite/.copywrite.hcl"
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Suppressed comments (3)
Previously missed (1) — in code that hasn't changed since the last review.
main/copywrite/headers/ccdc_slash.tmpl:6
- This proprietary-use restriction, also duplicated in the hash template and added headers, directly contradicts the repository's MIT
LICENSE, which permits copying, modification, and redistribution. Resolve the licensing intent before enforcing the header; if the repository remains MIT, use an MIT-compatible copyright header throughout.
// This code is Copyright (C) {{ .Year }} The Cambridge Crystallographic Data Centre (CCDC)
// of 12 Union Road, Cambridge CB2 1EZ, UK and a proprietary work of CCDC. This
// code may not be used, reproduced, translated, modified, disassembled or
// copied, except in accordance with a valid licence agreement with CCDC and
// may NOT be disclosed or redistributed in any form, either in whole or in
action.yml:29
- This invocation does not set
COPYWRITE_HOOK_ROOT, although bothlicense_headervalues interpolate it. Only the two wrapper scripts export that variable, so the composite-action path cannot resolve its templates and the new validation step fails. Set it for this command.
run: copywrite headers --config "$GITHUB_ACTION_PATH/main/copywrite/.copywrite.hcl" --plan
.pre-commit-hooks.yaml:30
- The manual hook repeats the invalid Python dependency setup: pre-commit passes
copywrite==1.1.3to pip rather than installing the HashiCorp Go CLI, so this hook cannot provision thecopywritecommand either. Switch it to the same supported CLI installation strategy as the check hook.
language: python
pass_filenames: false
stages: [manual]
additional_dependencies:
- copywrite==1.1.3
| language: python | ||
| pass_filenames: false | ||
| additional_dependencies: | ||
| - copywrite==1.1.3 |
| } | ||
|
|
||
| rule { | ||
| paths = ["**/*.py", "**/*.sh", "**/*.bash", "**/*.yaml", "**/*.yml"] |
| # START_LICENSE_TEXT | ||
| # This code is Copyright (C) {{ .Year }} The Cambridge Crystallographic Data Centre (CCDC) |
| @@ -0,0 +1,30 @@ | |||
| # | |||
| # This code is Copyright (C) <year> The Cambridge Crystallographic Data Centre | |||
No description provided.